<?php

class Admin_TourController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
       	$this->_helper->layout()->disableLayout();
		Zend_Loader::loadFile('../application/admin/models/Tour.php');

		$tour_module = new Tour();
		$tour_arr = $tour_module->getTourDetails();
		$this->view->tour_arr = $tour_arr;	
    } 
    
    public function addAction()
    {
    	$this->_helper->layout()->disableLayout();
		Zend_Loader::loadFile('../application/admin/forms/Tour.php');
		$tour_form = new Form_Tour();
        $this->view->title = "Add Tours";        
        $this->view->tour_form = $tour_form;
    }
    
    public function doaddtourAction()
	{
		Zend_Loader::loadFile('../application/admin/forms/Tour.php');
		Zend_Loader::loadFile('../application/admin/models/Tour.php');
		$form_tour = new Form_Tour();
		$request = $this->getRequest();
		
		if ($this->getRequest()->isPost()) {            
			$tour_model = new Tour();
			$form_values = $request->getPost();
			$add_tour = $tour_model->addTour($form_values);
		}
		
		exit;
	}
	
	public function editAction()
	{
		$this->_helper->layout()->disableLayout();
		Zend_Loader::loadFile('../application/admin/forms/Tour.php');
		Zend_Loader::loadFile('../application/admin/models/Tour.php');		
		$model_tour = new Tour();
		$request = $this->getRequest();
		$action = $this->getRequest()->getActionName();
		$tour_id = $request->getParam('tour_id', 0);
		$options = array("action"=>$action, "tour_id"=>$tour_id);
        $form_tour = new Form_Tour($options);
		$this->view->tour_form = $form_tour;        
        
		$tour_arr = $model_tour->getTourDetailsById($tour_id);
		
        $this->view->tour_id = $tour_id;
        if ($tour_id > 0) {            
            $this->view->tour_arr = $tour_arr;             
        }
	}
	
	public function updatetourAction()
    {
        $this->_helper->layout()->disableLayout();
   		Zend_Loader::loadFile('../application/admin/models/Tour.php');
		Zend_Loader::loadFile('../application/admin/forms/Tour.php');
        $tour_form = new Form_Tour();
        $request = $this->getRequest();
		if ($this->getRequest()->isPost()) {            
			$tour_model = new Tour();
			$form_values = $request->getPost();
			$update_tour = $tour_model->updateTour($form_values);
		}
		
		exit;
    }
    
    public function viewAction()
    {
    	$this->_helper->layout()->disableLayout();
   		Zend_Loader::loadFile('../application/admin/models/Tour.php');
		
   		$tour_model = new Tour();
   		$request = $this->getRequest();
   		$tour_id = $request->getParam('tour_id', 0);
   		
   		$tour_arr = $tour_model->getTourDetailsById($tour_id);
   		$this->view->tour_arr = $tour_arr;   			
    }
    
    public function deleteAction()
    {
    	$this->_helper->layout()->disableLayout();
   		Zend_Loader::loadFile('../application/admin/models/Tour.php');
		
   		$tour_model = new Tour();
   		$request = $this->getRequest();
   		$tour_id = $request->getParam('tour_id', 0);
   		$del_tour = $tour_model->deleteTour($tour_id);
    }
}